import {Panel} from 'comps/common';
import ServiceManageList from '../components/service-manager-list';
import * as ServiceAction from 'actions/service';
import { getFetchStatus } from 'actions/util';
import * as React from 'react';
import * as ReactRedux from 'react-redux';

const mapStateToProps = (state) => {
  return {
    isFetching: getFetchStatus(state, ServiceAction.fetchServiceListByApplication),
    services: state.serviceListByApplication
  };
};

const mapDispatchToProps = (dispatch) => {
  return {
    initFetch: (application) => {
      dispatch(ServiceAction.fetchServiceListByApplication(application));
    }
  };
};

class ApplicationDetail extends React.Component {

  componentDidMount() {
    this.props.initFetch(this.props.application);
  }

  render() {
    return (
      <Panel title="服务列表">
        <ServiceManageList {...this.props}/>
      </Panel>
    )
  }
}

export default ReactRedux.connect(mapStateToProps, mapDispatchToProps)(ApplicationDetail);
